<html>
<head><meta charset="utf-8"><title>compiler stages · t-compiler · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/index.html">t-compiler</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/compiler.20stages.html">compiler stages</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="136539823"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/compiler%20stages/near/136539823" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nikita Popov <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/compiler.20stages.html#136539823">(Oct 26 2018 at 11:14)</a>:</h4>
<p>I'm a bit confused about what exactly the stage0 and stage1 compilers are. I thought stage0 is the previous beta compiler and stage1 is the checkout built with the stage0 compiler. However, changing files in the checkout also triggers a (partial) rebuild of the stage0 compiler. Why is that?</p>



<a name="136540204"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/compiler%20stages/near/136540204" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/compiler.20stages.html#136540204">(Oct 26 2018 at 11:23)</a>:</h4>
<p>stage0 is only the compiler, there are no standard library binaries included. So the first thing the stage0 compiler does is build its libstd</p>



<a name="136540256"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/compiler%20stages/near/136540256" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/compiler.20stages.html#136540256">(Oct 26 2018 at 11:24)</a>:</h4>
<p>if you modify libstd/libcore or similar, then stage0 will rebuild that, causing a full stage 1 rebuild</p>



<a name="136540261"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/compiler%20stages/near/136540261" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/compiler.20stages.html#136540261">(Oct 26 2018 at 11:24)</a>:</h4>
<p>you can prevent this by passing <code>--keep-stage 0</code> to your command line</p>



<a name="136540640"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/compiler%20stages/near/136540640" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nikita Popov <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/compiler.20stages.html#136540640">(Oct 26 2018 at 11:32)</a>:</h4>
<p>So if I currently have a stage0 and stage1 compiler (default config), I run touch src/librustc/lib.rs &amp;&amp; ./x.py build --stage 1. This first skips building stage0 std and test and then does:<br>
Building stage0 compiler artifacts (x86_64-unknown-linux-gnu -&gt; x86_64-unknown-linux-gnu)<br>
   Compiling rustc v0.0.0 (/home/nikic/rust/src/librustc)<br>
   etc.</p>



<a name="136540662"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/compiler%20stages/near/136540662" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nikita Popov <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/compiler.20stages.html#136540662">(Oct 26 2018 at 11:33)</a>:</h4>
<p>It does not rebuild the stage0 libstd, but does seem to rebuild the stage0 compiler (or at least the parts that were changed)</p>



<a name="136541202"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/compiler%20stages/near/136541202" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/compiler.20stages.html#136541202">(Oct 26 2018 at 11:46)</a>:</h4>
<p>oh, well, not quite. It's building the compiler artifacts with the <code>stage0</code> compiler (because it doesn't have a stage1 compiler yet)</p>



<a name="136541251"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/compiler%20stages/near/136541251" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/compiler.20stages.html#136541251">(Oct 26 2018 at 11:46)</a>:</h4>
<p>the compiler that is being built is the stage 1 compiler</p>



<a name="136542307"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/compiler%20stages/near/136542307" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Nikita Popov <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/compiler.20stages.html#136542307">(Oct 26 2018 at 12:05)</a>:</h4>
<p>Ah, so I guess I should be interpreting "building stageN artifacts" not as "building artifacts for use in stageN" but rather "building artifacts using stageN for use in stageN+1", right?</p>



<a name="136546156"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/compiler%20stages/near/136546156" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/compiler.20stages.html#136546156">(Oct 26 2018 at 13:18)</a>:</h4>
<p>That’s how I understand it, yes.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>